/**
 * udes.ds.rmi
 * SummativeEquation.java
 * 3 sept. 08
 */
package udes.ds.rmi.hw;

/**
 * Stores an equation of the type Ax^n + Bx^(n-1) + ... + C
 * 
 * @author      Luc Bergevin
 * @version     1.0
 */
public class PolynomialEquation implements Equation {
	
	private static final long	 serialVersionUID	= 1L;
	private Equation _first;
	private Equation _second;
	
	public PolynomialEquation(Equation first, Equation second) {
		super();
		_first = first;
		_second = second;
	}

	public Equation getFirst() {
		return _first;
	}

	public Equation getSecond() {
		return _second;
	}

	/**  
	 * @see udes.ds.rmi.hw.Equation#getFunctionValue(double)      
	 */
	public double getFunctionValue(double x) {
		return (_first.getFunctionValue(x) + _second.getFunctionValue(x));
	}

	/**  
	 * @see udes.ds.rmi.hw.Equation#printUserReadable()      
	 */
	public void printUserReadable() {
		System.out.println("y = " + this.getUserReadableString());
	}

	/**   
	 * @see udes.ds.rmi.hw.Equation#getUserReadableString()      
	 */
	public String getUserReadableString() {
		return new String(_first.getUserReadableString() + " + " + _second.getUserReadableString());
	}

}
